require(['./config'], () => {
  require(['request', 'template','swiper','header','footer','jquery','bootstrap'], (request, template,Swiper) => {
    class Index {
      constructor() {
        this.banner()
        this.getGiftList()
      }
      banner () {
        // 实现轮播图功能
        new Swiper ('.swiper-container', {
          loop: true, // 循环模式选项
          // autoplay:true, //自动播放
          autoplay: {
            delay: 2000,
            stopOnLastSlide: false,
            disableOnInteraction: true,
            },
          // 如果需要分页器
          pagination: {
            el: '.swiper-pagination',
          },
          
          // 如果需要前进后退按钮
          navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
          },
          
          // 如果需要滚动条
          scrollbar: {
            el: '.swiper-scrollbar',
          },
        })
      }
      // 主页展示
      getGiftList () {
        // 利用rap2渲染
        request.getGiftList().then(resp => {
          if (resp.code === 200) {
            const { list } = resp.body
            const html = template('giftListTemplate', { list })
            $('#giftList').html(html)
          }
        })
      }
    }
    new Index()
  })
})